package com.xuecheng.media.conver;

import com.xuecheng.content.model.dto.MediaFilesTaskDto;
import com.xuecheng.content.model.po.MediaFiles;
import com.xuecheng.content.model.po.MediaProcess;
import com.xuecheng.content.model.po.MediaProcessHistory;

import java.time.LocalDateTime;

public class VideoTaskCover {

    public MediaProcess mediaFilesConverToMediaProcess(MediaFilesTaskDto mediaFilesTaskDto){
        MediaProcess mediaProcess = new MediaProcess();
        mediaProcess.setFileId(String.valueOf(mediaFilesTaskDto.getId()));
        mediaProcess.setFilename(mediaFilesTaskDto.getFilename());
        mediaProcess.setBucket(mediaFilesTaskDto.getBucket());
        mediaProcess.setFilePath(mediaFilesTaskDto.getFilePath());
        mediaProcess.setStatus("1");
        mediaProcess.setCreateDate(LocalDateTime.now());
        mediaProcess.setFailCount(mediaFilesTaskDto.getFailCount());
        mediaProcess.setUrl(mediaFilesTaskDto.getUrl());
        mediaProcess.setId(mediaFilesTaskDto.getMediaProcessHistoryId());

        return mediaProcess;
    }

    public MediaProcessHistory mediaFilesConverToMediaProcessHistory(MediaFiles mediaFiles){
        MediaProcessHistory mediaProcessHistory = new MediaProcessHistory();
        mediaProcessHistory.setFileId(String.valueOf(mediaFiles.getId()));
        mediaProcessHistory.setFilename(mediaFiles.getFilename());
        mediaProcessHistory.setBucket(mediaFiles.getBucket());
        mediaProcessHistory.setFilePath(mediaFiles.getFilePath());
        mediaProcessHistory.setStatus("1");
        mediaProcessHistory.setCreateDate(LocalDateTime.now());
        mediaProcessHistory.setFailCount(0);
        mediaProcessHistory.setUrl(mediaFiles.getUrl());

        return mediaProcessHistory;
    }
}
